/****************************************************
 * Description: Entity for 菜单
 * Copyright:   Copyright (c) 2013
 * Company:     beiwaionline
 * @author      bfsu
 * @version     1.0
 * @see
	HISTORY
    *  2013-08-08 bfsu Create File
**************************************************/

package com.bfsuolframework.security.entity;


import java.util.Collection;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.bfsuolframework.core.entity.Entity;
import com.bfsuolframework.core.entity.EntitySupport;


public class Menu extends EntitySupport implements Entity {

    private static final long serialVersionUID = 1L;

    public Menu(){}
    public Menu(Long id){
        this.id = id;
    }

    private Long id;
    private String title;//名称
    private String description;//描述
    private Long parentId;//父菜单
    private String privilegeCode;//对应权限
    private String url;//菜单地址
    private Integer isSys;//是否系统菜单
    private Integer isEnabled;//是否可用
    private Integer orderSn=(id==null?null:id.intValue());//菜单排序
    private Collection<Menu> subMenus;//子菜单
    /**
     * @return 主键
     */
    public Long getId() {
        return id;
    }
    /**
     * @param 主键
     */
    public void setId(Long id) {
        this.id = id;
    }
    
    /**
     * @return 名称
     */
    public String getTitle() {
        return title;
    }
    
    /**
     * @param 名称
     */
    public void setTitle(String title) {
        this.title = title;
    }
    
    /**
     * @return 描述
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * @param 描述
     */
    public void setDescription(String description) {
        this.description = description;
    }
    
    /**
     * @return 父菜单
     */
    public Long getParentId() {
        return parentId;
    }
    
    /**
     * @param 父菜单
     */
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }
    
    /**
     * @return 对应权限
     */
    public String getPrivilegeCode() {
        return privilegeCode;
    }
    
    /**
     * @param 对应权限
     */
    public void setPrivilegeCode(String privilegeCode) {
        this.privilegeCode = privilegeCode;
    }
    
    /**
     * @return 菜单地址
     */
    public String getUrl() {
        return url;
    }
    
    /**
     * @param 菜单地址
     */
    public void setUrl(String url) {
        this.url = url;
    }
    
    /**
     * @return 是否系统菜单
     */
    public Integer getIsSys() {
        return isSys;
    }
    
    /**
     * @param 是否系统菜单
     */
    public void setIsSys(Integer isSys) {
        this.isSys = isSys;
    }
    
    /**
     * @return 是否可用
     */
    public Integer getIsEnabled() {
        return isEnabled;
    }
    
    /**
     * @param 是否可用
     */
    public void setIsEnabled(Integer isEnabled) {
        this.isEnabled = isEnabled;
    }
    
    /**
     * 排序序号
     * @return
     */
    public Integer getOrderSn() {
		return orderSn;
	}
    /**
     * 设置排序序号
     * @param orderSn
     */
	public void setOrderSn(Integer orderSn) {
		this.orderSn = orderSn;
	}
	/**
     * 子菜单
     * @return
     */
    public Collection<Menu> getSubMenus() {
		return subMenus;
	}
	public void setSubMenus(Collection<Menu> subMenus) {
		this.subMenus = subMenus;
	}
	public int hashCode() {
        return new HashCodeBuilder().append("Menu").append(this.getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (getClass() != obj.getClass())
            return false;
        if (!(obj instanceof Menu))
            return false;
        final Menu that = (Menu)obj;
        return new EqualsBuilder().append(this.getId(), that.getId()).isEquals();
    }

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).append("Menu").append("ID="+this.getId()).toString();
    }

}

